/*
 * Copyright (c) 2009-2013 EvTech Project
 * All rights reserved.
 * 
 * This file is part of LModeller.
 *
 * LModeller is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version.
 *
 * LModeller is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with LModeller.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package fi.honkalampisaatio.lmodeller.ui;

import org.lwjgl.util.Rectangle;

import fi.honkalampisaatio.lmodeller.LModeller;
import fi.honkalampisaatio.lmodeller.ui.GameButton.TEXTLOCATION;
import fi.honkalampisaatio.lmodeller.xml.User;
import fi.honkalampisaatio.lwjgl.GLTexture;

public class UserButton extends UIElement {

	GameButton imgButton;
	GameTextLabel textButton;
	User user;

	UserButton(Rectangle rec, User user) {
		super(rec);
		this.user = user;
		String userId = Integer.toString(user.getUserId());
		GameTextures.getInstance().add(userId, user.getMenuimage());
		imgButton = new GameButton(new Rectangle(rec.getX(),rec.getY(),rec.getWidth(),rec.getHeight()*4/5), 
				GameTextures.getInstance().getTexture(userId), LModeller.actionColor, null, TEXTLOCATION.UP);
		textButton = new GameTextLabel(new Rectangle(rec.getX(),rec.getY()+rec.getHeight()*4/5, rec.getWidth(),rec.getHeight()/5), 
				rec.getHeight()/6, LModeller.actionColor);
		textButton.setText(user.getName());
	}
	

	public void paint()
	{
		imgButton.render();
		textButton.render();
	}

	public User getUser()
	{
		return user;
	}


	public GLTexture getTexture() {
		return imgButton.getTexture();
	}
}
